﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UmlDesigner.Model;

namespace UmlDesigner.Gui
{
    public partial class NewArgumentForm : Form
    {
        internal NewArgumentForm(Argument arg)
        {
            InitializeComponent();

            argument = arg;
            nameTextBox.Text = argument.name;
            typeTextBox.Text = argument.type;
            ValidateInput();
        }

        Argument argument;

        private void button1_Click(object sender, EventArgs e)
        {
            argument.name = nameTextBox.Text;
            argument.type = typeTextBox.Text;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            TypeSelectionForm dlg = new TypeSelectionForm();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                typeTextBox.Text = dlg.selectedType;
            }
        }

        private void nameTextBox_TextChanged(object sender, EventArgs e)
        {
            ValidateInput();
        }

        private void typeTextBox_TextChanged(object sender, EventArgs e)
        {
            ValidateInput();
        }

        private void ValidateInput()
        {
            button1.Enabled = (nameTextBox.Text.Length > 0 && typeTextBox.Text.Length > 0);
        }
    }
}
